<template>
	<view style="height: 100vh;background-color: aliceblue;">
		<!-- 头部按钮 -->
		<view class="headerbutton">
			<u-button :ripple="true" @click="touch1" type="primary" class="custom-style" text="课程表" icon="level"></u-button>
			<u-button @click="touch1" type="primary" class="custom-style" text="未完成任务" icon="level"></u-button>
		</view>
		<!-- 标签区域 -->
		<view class="front">
			<u-tabs :list="list1" @click="click"></u-tabs>
			<u-tabs style="margin-top: 20rpx;" @click="tou" v-if="flay" :list="list2"></u-tabs>
			<view class="contbox" @click="ado">
				<view class="" v-if="!flay">
					<classs :duration="video[2].duration" :title="video[2].title" :video_img="video[2].video_img" ></classs>
				</view>
				<view class="" v-else>
					<view v-for="(item,index) in video" :key="index">
						<classs  :duration="item.duration" :title="item.title" :video_img="item.video_img" ></classs>
						
					</view>
				</view>
			</view>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				ip:"http://127.0.0.1:8081/",
				flay:false,
				list1: [{
				            name: '直播课',
				       }, {
				          name: '录播课',
				    }],
				list2:[
					{name:""},
					{name:""},
					{name:""},
					{name:""},
					{name:""}
				],
				video:[]
			}
		},
		onLoad() {
			this.getcate()
		},
		methods: {
			async getcate(){
				const data1=await this.$request.getvideos()
				this.video=data1.data.data
				console.log(this.video)
			const data=await this.$request.getvideocate()
			this.list2.forEach((item,index)=>{
				// console.log(data.data.data[index].categoryName)
				item.name=data.data.data[index].categoryName
			})
			},
			async tou(e){
				const data1=await this.$request.getvideos()
				this.video=data1.data.data
				this.video=this.video.filter(item=>{
					return item.videoID_category==e.index+1
				})
				// console.log(e)
			},
			touch1(){
				console.log(111)
				uni.navigateTo({
					url:"/pages/study/taber/taber"
				})
			},
			// 更改请求需要
			click(){
				this.flay=!this.flay
			},
			ado(){
				uni.navigateTo({
					url:"/pages/index/classlist/void"
				})
			}
		}
	}
</script>

<style lang="scss">
	.contbox{
		width: 95%;
		margin: 20rpx auto;
	}
	.headerbutton{
		display: flex;
		justify-content: center;
		margin-top: 10px;
	}
	.headerbutton>*{
		margin: 0px 10px;
		border-radius: 10px;
	}

</style>
